package com.ruoyi.app.controller;
import com.ruoyi.admin.service.MemberService;
import com.ruoyi.admin.service.TravelRouteService;
import com.ruoyi.app.domain.*;
import com.ruoyi.app.dto.ArticleDto;
import com.ruoyi.app.dto.UserDto;
import com.ruoyi.app.service.HomeService;
import com.ruoyi.app.service.UserService;
import com.ruoyi.common.utils.PermissionAnnotate;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;

/*
@description:首页
@ClassName HomeController
@author chen
@create 2025-03-13 23:49
@Version 1.0
*/
@Slf4j
@RestController
@RequestMapping("app")
@AllArgsConstructor
public class HomeController extends BaseController
{
    final UserService userService;
    final HomeService homeService;
    final MemberService memberService;
    final TravelRouteService travelRouteService;

    /*
     * @==============History===============<br/>
     * @Description //   小程序获取用户列表数据
     * @Date 2025-3-13 23:08
     * @Author < a href="15991488967@163.com">chen</ a>
     * @return com.ruoyi.framework.web.page.TableDataInfo
     */
    @GetMapping(value = "/getUserInfoList",produces = "application/json;charset=utf-8")
    public TableDataInfo getUserInfoList(@RequestParam Map<String, Object> params)
    {
        startPage();
        List<UserDto> list = userService.getUserInfoList(params);
        return getDataTable(list);
    }

    /*
     * @==============History===============<br/>
     * @Description //   小程序获取视频信息
     * @Date 2025-3-13 23:51
     * @Author < a href="15991488967@163.com">chen</ a>
     * @return com.ruoyi.framework.web.domain.AjaxResult
     */
    @GetMapping(value = "/getVideoInfo",produces = "application/json;charset=utf-8")
    public TableDataInfo getVideoInfo(@RequestParam Map<String, Object> params)
    {
        startPage();
        List<VideoInfo> list = homeService.getVideoInfo(params);
        return getDataTable(list);
    }


    /*
     * @==============History===============<br/>;
     * @Description // 获取图片信息
     * @Date 2025/3/14
     * @Author < a href="chencheng@prmt.net">chen</ a>;
     */
    @GetMapping(value = "/getPictureInfo",produces = "application/json;charset=utf-8")
    public TableDataInfo getPictureInfo(@RequestParam Map<String, Object> params)
    {
        startPage();
        List<PictureInfo> list = homeService.getPictureInfo(params);
        return getDataTable(list);
    }


    /*
     * @==============History===============<br/>
     * @Description //  小程序获取会员列表
     * @Date 2025-3-16 21:57
     * @Author < a href="15991488967@163.com">chen</ a>
     * @return com.ruoyi.framework.web.page.TableDataInfo
     */
    @GetMapping(value = "/getMemberList",produces = "application/json;charset=utf-8")
    public TableDataInfo getMemberList(@RequestParam Map<String, Object> params)
    {
        startPage();
        List<Member> list = memberService.getMemberList(params);
        return getDataTable(list);
    }


    /*
     * @==============History===============<br/>;
     * @Description //   小程序获取文章列表
     * @Date 2025/3/18
     * @Author < a href="chencheng@prmt.net">chen</ a>;
     */
    @GetMapping(value = "/getArticleInfoList",produces = "application/json;charset=utf-8")
    public TableDataInfo getArticleInfoList(@RequestParam Map<String, Object> params)
    {
        startPage();
        List<ArticleDto> list = homeService.getArticleInfoList(params);
        return getDataTable(list);
    }


    /*
     * @==============History===============<br/>;
     * @Description // 根据文章id获取文章详情
     * @Date 2025/3/18
     * @Author < a href="chencheng@prmt.net">chen</ a>;
     */
    @GetMapping(value = "/getArticleInfo",produces = "application/json;charset=utf-8")
    public AjaxResult getArticleInfo(@RequestParam Map<String, Object> params)
    {
        return AjaxResult.success(homeService.getArticleInfo(params));
    }



    /*
     * @==============History===============<br/>;
     * @Description //   小程序获取行程列表
     * @Date 2025/3/18
     * @Author < a href="chencheng@prmt.net">chen</ a>;
     */
    @PermissionAnnotate(operateType = "行程模块", operateExplain = "行程列表", sourceType = "controller")
    @GetMapping(value = "/getTripInfoList",produces = "application/json;charset=utf-8")
    public TableDataInfo getTripInfoList(@RequestParam Map<String, Object> params)
    {
        startPage();
        List<TripInfo> list = homeService.getTripInfoList(params);
        return getDataTable(list);
    }


    /*
     * @==============History===============<br/>;
     * @Description // 根据行程id获取行程详情
     * @Date 2025/3/18
     * @Author < a href="chencheng@prmt.net">chen</ a>;
     */
    @GetMapping(value = "/getTripInfo",produces = "application/json;charset=utf-8")
    public AjaxResult getTripInfo(@RequestParam Map<String, Object> params)
    {
        return AjaxResult.success(homeService.getTripInfo(params));
    }


    @GetMapping(value = "/getTravelRouteById",produces = "application/json;charset=utf-8")
    public AjaxResult getTravelRouteById(@RequestParam("id") Long id)
    {
        return travelRouteService.getTravelRouteById(id);
    }


    @GetMapping(value = "/getTravelRouteList",produces = "application/json;charset=utf-8")
    public TableDataInfo getTravelRouteList(@RequestParam Map<String,Object> params)
    {
        startPage();
        List<TravelRoute> list = travelRouteService.getTravelRouteList(params);
        return getDataTable(list);
    }
}
